﻿<phone:PhoneApplicationPage 
    x:Class="Url2Ringtone.Browser"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:browser="clr-namespace:FullBrowserControl"
    xmlns:int="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:Behaviour="clr-namespace:Url2Ringtone.Behaviours"
    xmlns:phonefx="clr-namespace:Phone7.Fx.Controls;assembly=Phone7.Fx"
    xmlns:daniel="clr-namespace:DanielVaughan.Windows"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    DataContext="{Binding Source={StaticResource Locator}, Path=BrowserViewModel}"
    shell:SystemTray.IsVisible="True">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <daniel:ProgressIndicatorProxy IsIndeterminate="{Binding ElementName=fullBrowser, Path=ShowProgress}"
                                       IsVisible="{Binding ElementName=fullBrowser, Path=ShowProgress}"
                                       Text="{Binding Source={StaticResource StringsManager}, Path=Strings.Loading, Mode=OneTime}"/>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,0">
            <TextBlock x:Name="ApplicationTitle" Text="{StaticResource AppName}" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <browser:FullWebBrowser x:Name="fullBrowser" browser:Navigating="fullBrowser_Navigating" browser:Navigated="fullBrowser_Navigated" Grid.Row="0" History="{Binding History, Mode=TwoWay}" InitialUri="{Binding NavigateUrl}"/>
            <toolkit:PhoneTextBox Grid.Row="1" 
                                  InputScope="Url" 
                                  KeyUp="TextBox_KeyUp" 
                                  Text="{Binding ElementName=fullBrowser, Path=CurrentUrl}" 
                                  ActionIcon="/Icons/clearboxicon.png"
                                  ActionIconTapped="PhoneTextBox_ActionIconTapped">
                <int:Interaction.Behaviors>
                    <Behaviour:UpdateTextBindingOnPropertyChanged/>
                </int:Interaction.Behaviors>
            </toolkit:PhoneTextBox>
        </Grid>
        
        <phonefx:BindableApplicationBar IsVisible="True">
        	<phonefx:BindableApplicationBar.Buttons>
                <phonefx:BindableApplicationBarIconButton Text="{Binding Source={StaticResource StringsManager}, Path=Strings.BrowserBack, Mode=OneTime}" 
                                                          IconUri="/Icons/appbar.back.rest.png"
                                                          x:Name="btnBack"
                                                          Click="btnBack_Click"/>
                <phonefx:BindableApplicationBarIconButton Text="{Binding Source={StaticResource StringsManager}, Path=Strings.BrowserRefresh, Mode=OneTime}" 
                                                          IconUri="/Icons/appbar.refresh.rest.png"
                                                          x:Name="btnRefresh"
                                                          Click="btnRefresh_Click"/>
                <phonefx:BindableApplicationBarIconButton Text="{Binding Source={StaticResource StringsManager}, Path=Strings.BrowserForward, Mode=OneTime}" 
                                                          IconUri="/Icons/appbar.next.rest.png"
                                                          x:Name="btnForward"
                                                          Click="btnForward_Click"/>
                <phonefx:BindableApplicationBarIconButton Text="{Binding Source={StaticResource StringsManager}, Path=Strings.Add, Mode=OneTime}" 
                                                          IconUri="/Icons/appbar.favs.addto.rest.png"
                                                          x:Name="btnAddFavourite"
                                                          Click="btnAddFavourite_Click"/>
			</phonefx:BindableApplicationBar.Buttons>
            <phonefx:BindableApplicationBar.MenuItems>
                <phonefx:BindableApplicationBarMenuItem Text="{Binding Source={StaticResource StringsManager}, Path=Strings.Recent, Mode=OneTime}"
														x:Name="btnRecent"
														IsEnabled="True"
														Click="btnRecent_Click"/>
                <phonefx:BindableApplicationBarMenuItem Text="{Binding Source={StaticResource StringsManager}, Path=Strings.Settings, Mode=OneTime}"
														x:Name="btnSettings"                                                        
														Click="btnSettings_Click"/> 
				<phonefx:BindableApplicationBarMenuItem Text="{Binding SmartBrowsingText}"
                                                        Visibility="{Binding UseSmartBrowsing, Converter={StaticResource InvertedVisibilityConverter}}"
														x:Name="btnSmartBrowsing"
														Click="btnSmartBrowsing_Click"/>        
			</phonefx:BindableApplicationBar.MenuItems>
        </phonefx:BindableApplicationBar>
    </Grid>
</phone:PhoneApplicationPage>
